export const handleFlawFilterData = flawCongig => {
    let fatherFlawTrue = {};
    let fatherFlawFalse = {};
    let sonFlawTrue = {};
    let sonFlawFalse = {};
    let defaultFlaw = {};
    let defaultFlawArr = [] as number[];

    let checkLV1 = {};
    let checkLV2 = {};
    let checkLV3 = {};
    let hasChildNum = {}; // 每个父缺陷有几个子缺陷

    flawCongig.forEach(item => {
        item.children.forEach(val => {
            fatherFlawTrue[val.id] = true;
            fatherFlawFalse[val.id] = false;
            defaultFlaw[val.id] = [];
            const rowArr = [] as any;
            val.children.forEach(child => {
                rowArr.push(child.id);
                if (String(child.id).endsWith('01')) {
                    checkLV1[val.id] = Number(child.id);
                    defaultFlaw[val.id] = [child.id];
                    defaultFlawArr.push(child.id);
                }
                if (String(child.id).endsWith('02')) {
                    checkLV2[val.id] = Number(child.id);
                }
                if (String(child.id).endsWith('03')) {
                    checkLV3[val.id] = Number(child.id);
                }
            });
            sonFlawTrue[val.id] = rowArr;
            sonFlawFalse[val.id] = [];
            hasChildNum[val.id] = val.children.length; // 每个父缺陷有几个子缺陷---
        });
    });

    // console.log('fatherFlawTrue', fatherFlawTrue);
    // console.log('fatherFlawFalse', fatherFlawFalse);
    // console.log('sonFlawTrue', sonFlawTrue);
    // console.log('sonFlawFalse', sonFlawFalse);
    // console.log('-------------------------------');
    // console.log('checkLV1', checkLV1);
    // console.log('checkLV2', checkLV2);
    // console.log('checkLV3', checkLV3);
    // console.log('defaultFlaw---', defaultFlaw);

    return {
        fatherFlawTrue: fatherFlawTrue,
        fatherFlawFalse: fatherFlawFalse,
        sonFlawTrue: sonFlawTrue,
        sonFlawFalse: sonFlawFalse,
        checkLV1: checkLV1,
        checkLV2: checkLV2,
        checkLV3: checkLV3,
        defaultFlaw: defaultFlaw,
        defaultFlawArr: defaultFlawArr,
        hasChildNum:hasChildNum
    };
};
